#!/usr/bin/env bash
set -e

status=0

export PATH="${PWD}/bin:$PATH"

for db in sqlite3 mysql mysql2 postgres; do
  if ! [[ $db = "mysql2" && $BUNDLE_GEMFILE =~ "rails3.0" ]]; then
    printf "\e[1;33m[DB] ${db}\e[m\n"
    spec_files="spec"
    [[ $db != "sqlite3" ]] && spec_files="spec/finders/active_record_spec.rb"
    echo "rspec $spec_files"
    DB=$db rspec -r fake_rubygems $spec_files || status="$?"
  fi
done

exit $status
